// 数组移动

export enum MoveType {
  MOVE_UP,
  MOVE_DOWN
}

export function moveFn(arr: any[], curIndex: number, moveIndex: number) {
  arr[curIndex] = arr.splice(moveIndex, 1, arr[curIndex])[0]
  return arr
}

export function moveList(arr: any[], type: MoveType, curIndex: number) {
  switch (type) {
    case MoveType.MOVE_UP:
      curIndex !== 0 && moveFn(arr, curIndex, curIndex - 1)
      break
    case MoveType.MOVE_DOWN:
      curIndex !== arr.length - 1 && moveFn(arr, curIndex, curIndex + 1)
      break
  }
}
